package com.caishi.lkx.exam.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.caishi.lkx.exam.mapper.HotShareMapper;
import com.caishi.lkx.exam.model.HotSharedModel;
import com.caishi.lkx.exam.service.IHotShareService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

@Service
public class HotShareServiceImpl implements IHotShareService {
    @Resource
    private HotShareMapper hotShareMapper;
    @Override
    public boolean saveBatch(Collection<HotSharedModel> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<HotSharedModel> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<HotSharedModel> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(HotSharedModel entity) {
        return false;
    }

    @Override
    public HotSharedModel getOne(Wrapper<HotSharedModel> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<HotSharedModel> queryWrapper) {
        return Map.of();
    }

    @Override
    public <V> V getObj(Wrapper<HotSharedModel> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public BaseMapper<HotSharedModel> getBaseMapper() {
        return hotShareMapper;
    }

    @Override
    public Class<HotSharedModel> getEntityClass() {
        return HotSharedModel.class;
    }
    public IPage<HotSharedModel> getHotSharedPage(int currentPage, int pageSize, QueryWrapper<HotSharedModel> queryWrapper) {
        // 创建 Page 对象
        Page<HotSharedModel> page = new Page<>(currentPage, pageSize);

        // 使用 QueryWrapper 构建查询条件
        // queryWrapper.eq("some_field", someValue); // 根据需要添加查询条件

        // 执行分页查询
        return this.page(page, queryWrapper);
    }
    @Override
    public List<HotSharedModel> getHotShares() {
//        BaseMapper<HotSharedModel> baseMapper = getBaseMapper();
//        QueryWrapper<HotSharedModel> queryWrapper = new QueryWrapper<>();
//        queryWrapper.select("")
//                .orderByDesc("create_time");
//        Page<HotSharedModel> page = new Page<>(1, 10);
        return hotShareMapper.getHotSharedList();

    }
}
